// 生成 html
const HtmlWebpackPlugin = require('html-webpack-plugin');
// 抽取 css
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// vue
const { VueLoaderPlugin } = require('vue-loader')
const path = require('path');
module.exports = {
    entry: './src/main.js', //入口
    output: {   //出口
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',  //出口名  
    },
    plugins: [
        new HtmlWebpackPlugin({ template: "./public/index.html" }),
        new MiniCssExtractPlugin({ filename: '[name].css', ignoreOrder: false }),
        new VueLoaderPlugin()
    ],
    mode: "development",
    devtool: 'cheap-module-source-map',
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.less$/i,
                use: ["style-loader", "css-loader", "less-loader"],
            },
            {
                test: /\.m?js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.css$/i,
                use: [MiniCssExtractPlugin.loader, 'css-loader'],
            },
            {
                test: /\.vue$/,
                use: 'vue-loader'
            }
        ],
    },
};